<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="View Sales Order # #{salesOrderEntityController.selected.id}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form rendered="#{loginBacking.viewSalesOrder}">
                <p:panel header="Sales Order Status:">
                    <p:tabView activeIndex="#{salesOrderEntityController.selected.activeIndex}" style="color:darkorange">
                        <p:tab title="Credit Check">

                        </p:tab>
                        <p:tab title="Inventory Sourcing">

                        </p:tab>
                        <p:tab title="Inventory Sourcing">

                        </p:tab>
                        <p:tab title="Confirmation">

                        </p:tab>
                        <p:tab title="Delivery">

                        </p:tab>
                        <p:tab title="Payment">

                        </p:tab>
                        <p:tab title="Completed">

                        </p:tab>   
                    </p:tabView>
                </p:panel>
                <p:tabView effect="opacity" effectDuration="normal" dynamic="false" cache="true"> 

                    <p:messages />
                    <br />
                    <p:tab title="Sales Order Detail" >                       
                        <ui:include src="/entities/salesOrderEntity/ViewSO.xhtml" />
                        <ui:include src="/entities/salesOrderEntity/ViewMetaInfo.xhtml" />
                    </p:tab>
                    <p:tab title="Purchase Order" >              
                        <ui:include src="/entities/purchaseOrderEntity/ViewToBeIncluded.xhtml" />
                    </p:tab>
                    <p:tab title="Shipping Information" > 
                        <ui:include src="/entities/shippingRequestEntity/ListShippingRequests.xhtml" />
                        <ui:include src="/entities/shippingOrderEntity/ListForSOForInclude.xhtml" />
                    </p:tab>
                    <p:tab title="Credit Payment" > 
                        <ui:include src="/entities/salesOrderEntity/ViewCreditPayment.xhtml" />
                        <ui:include src="/entities/billingRequestEntity/ListToBeIncluded.xhtml" />
                    </p:tab>                                        

                </p:tabView>
                <br />
                <p:panel header="Amend Sales Order Quantity">
                <h:panelGrid columns="5">
                        <h:outputLabel value="Product:" style="font-weight:bold"/>
                        <h:outputLabel value="Quantity:" style="font-weight:bold"/>
                        <h:outputLabel value="Price Per Unit (S$)" style="font-weight:bold"/>
                        <h:outputLabel value="Sub Total Price (S$)" style="font-weight:bold"/>
                        <h:outputLabel value=""/>

                        <h:outputLabel value="Classic Nutri Bar (Nuts)" />
                        <p:inputText id="quantity" binding="#{quantity1}" value="#{purchaseOrderEntityController.selectedPQP.quantity}" title="#{bundle.CreateProductQuantityPriceEntityTitle_quantity}" >
                            <p:ajax event="keyup" update="price and pricepu"   
                                    listener="#{purchaseOrderEntityController.calculatePQP}"/>  
                        </p:inputText>
                        <h:outputText id="pricepu" value="#{purchaseOrderEntityController.selectedPQP.pricePerUnit}" />
                        <h:outputText id="price" value="#{purchaseOrderEntityController.selectedPQP.price}" />
                        <h:outputLabel value=""/>

                        <h:outputLabel value="Classic Nutri Bar (Fruits)" />
                        <p:inputText id="quantity2" binding="#{quantity2}" value="#{purchaseOrderEntityController.selectedPQP2.quantity}" title="#{bundle.CreateProductQuantityPriceEntityTitle_quantity}" >
                            <p:ajax event="keyup" update="price2 and pricepu2"   
                                    listener="#{purchaseOrderEntityController.calculatePQP2}"/>  
                        </p:inputText>
                        <h:outputText id="pricepu2" value="#{purchaseOrderEntityController.selectedPQP2.pricePerUnit}" />
                        <h:outputText id="price2" value="#{purchaseOrderEntityController.selectedPQP2.price}" />
                        <h:outputLabel value=""/>

                        <h:outputLabel value="Premium Power Bar (Chocolate Nuts)" />
                        <p:inputText id="quantity3" binding="#{quantity3}" value="#{purchaseOrderEntityController.selectedPQP3.quantity}" title="#{bundle.CreateProductQuantityPriceEntityTitle_quantity}" >
                            <p:ajax event="keyup" update="price3 and pricepu3"   
                                    listener="#{purchaseOrderEntityController.calculatePQP3}"/>  
                        </p:inputText>
                        <h:outputText id="pricepu3" value="#{purchaseOrderEntityController.selectedPQP3.pricePerUnit}" />
                        <h:outputText id="price3" value="#{purchaseOrderEntityController.selectedPQP3.price}"/>
                        <h:outputLabel value=""/>

                        <h:outputLabel value="Premium Power Bar (Redcurrant Fruits)" />
                        <p:inputText id="quantity4" value="#{purchaseOrderEntityController.selectedPQP4.quantity}" title="#{bundle.CreateProductQuantityPriceEntityTitle_quantity}" >
                            <p:ajax event="keyup" update="price4 and pricepu4"   
                                    listener="#{purchaseOrderEntityController.calculatePQP4}"/>  
                            <f:validator validatorId="macTeam.ProductQuantityInputValidator"/>
                            <f:attribute name="quantity1" value="#{quantity1.value}" />
                            <f:attribute name="quantity2" value="#{quantity2.value}" />
                            <f:attribute name="quantity3" value="#{quantity3.value}" />
                        </p:inputText>
                        <h:outputText id="pricepu4" value="#{purchaseOrderEntityController.selectedPQP4.pricePerUnit}" />
                        <h:outputText id="price4" value="#{purchaseOrderEntityController.selectedPQP4.price}" />
                        <h:message styleClass="errorMsg" for= "quantity4" />
                    </h:panelGrid>
                </p:panel>
                <p:commandButton value="Save" action="#{purchaseOrderEntityController.updateEdit}" ajax="false"/>
                &nbsp;
                <p:commandButton value="Cancel" action="View" ajax="false"/>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
